package com.peakmain.systemmoudle;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.peakmain.sysemmoudle.R;
import com.peakmain.sysemmoudle.R2;
import com.peakmain.systemmoudle.adapter.SystemTreeLeftAdapter;
import com.peakmain.systemmoudle.base.BaseSystemFragment;
import com.peakmain.systemmoudle.contract.SystemTreeContract;
import com.peakmain.systemmoudle.presenter.SystemTreePresenter;
import com.peakmain.baselibrary.widget.FlowLayout;
import com.peakmain.wanandroid.netmodule.bean.system.SystemTreeBean;

import java.util.List;

import butterknife.BindView;

public class SystemFragment extends BaseSystemFragment<SystemTreePresenter> implements SystemTreeContract.View {

    @BindView(R2.id.recycler_view_left)
    RecyclerView mRecyclerViewLeft;
    @BindView(R2.id.flow_layout)
    FlowLayout mFlowLayout;

    private SystemTreeLeftAdapter mLeftAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_system;
    }

    @Override
    protected void initInjector() {
        mFragmentComponent.inject(this);
    }

    @Override
    protected void initView(View view) {
        mPresenter.getSystemTree();
    }

    @Override
    public void showSystemTreeSuccess(final List<SystemTreeBean> beans) {
        mLeftAdapter = new SystemTreeLeftAdapter(getContext(), beans, mFlowLayout);
        mRecyclerViewLeft.setLayoutManager(new LinearLayoutManager(getContext()));
        mRecyclerViewLeft.setAdapter(mLeftAdapter);
        //设置默认
        mLeftAdapter.setSelected(0);

    }

}
